
//相关业务逻辑
$(function(){
	page.bind();
	page.getShenHeOrder();
});


var page={//页面总变量
		bind:function(){
			$("#deleteBtn").bind("click",function(){
				var id="";
				 $.each($('input:checkbox:checked'),function(){
					 id+=$(this).val()+","; 
		            });
				 if(""==id){
					 layAlert("请选择要删除的订单");
				 }
				 var sendData={
							'id':id
				 }
			     ajaxUtil.ajaxRuquest('weiXin/deleteOder',sendData,function(data){
			    	 layer.msg(data, {icon: 1});
			    	 page.getShenHeOrder();
				 });
			});
			
			$("#shenHeBtn").bind("click",function(){
				var id="";
				$.each($('input:checkbox:checked'),function(){
					id+=$(this).val()+","; 
				});
				if(""==id){
					layAlert("请选择要审批的订单");
				}
				var sendData={
						'userName':$("#userName").text(),
						'id':id
				}
				ajaxUtil.ajaxRuquest('weiXin/shenHeOrder',sendData,function(data){
					layer.msg(data, {icon: 1});
					page.getShenHeOrder();
				});
			});

		},
		getShenHeOrder:function(){
			var sendData={
					'userName':$("#userName").text()
			}
			ajaxUtil.ajaxRuquest('weiXin/getShenHeOrder',sendData,function(data){
				if(data.length>0){
					page.setTable(data);
				}else{
					$("#shenHeTable").html("");
				}
			});
		},
		setTable:function(data){
			var html="<table class='table table-border  table-bg table-hover'>"; 
			for(var i=0;i<data.length;i++){
				  html+="<tr><td><input type='checkbox' name='sheHe' value="+data[i].id+"></td>"+
				  "<td>订单编号："+data[i].orderId+"<br/>"+
				  "工序名称: "+data[i].procedur+"<br/>"+
				  "颜&nbsp;&nbsp;&nbsp;&nbsp;色: "+data[i].color+"<br/>"+
				  "加工对象："+data[i].machining+"<br/>"+
				  "合  格 数："+data[i].qualified+"<br/>"+
				  "不合格数："+data[i].noQualified+"</br>"+
				  "日&nbsp;&nbsp;&nbsp;&nbsp;期："+data[i].time+"<br/>"+
				  "制  单 人："+data[i].touchPeople+"<br/></td></tr>";
			  }
			html+="</table>";
			$("#shenHeTable").html("");
			$("#shenHeTable").append(html);
		}
}


